package com.android.cargoapp.cargoapp_gui_prototype.settings;

import com.android.cargoapp.cargoapp_gui_prototype.R;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.widget.Toast;

public class Settings extends PreferenceActivity {
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		// Nicht schlimm :) --> sieh API
		addPreferencesFromResource(R.xml.activity_settings);
		
		Preference customPref = (Preference) findPreference("customPref");
		customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
			
			public boolean onPreferenceClick(Preference preference) {
				
				Toast.makeText(getBaseContext(), "The custom preference has been clicked", Toast.LENGTH_LONG).show();
				
				SharedPreferences customSharedPreference = getSharedPreferences("myCustomSharedPrefsBlaa", Activity.MODE_PRIVATE);
				SharedPreferences.Editor editor = customSharedPreference.edit();
				editor.putString("myCustomPrefBlaaaa", "The preference has been clicked...");
				editor.commit();
				return true;
			}
			
		});
	}
}
